package chapter5;

public class RollDicesSnakeEyes 
{
	private static int diceNumber1 =0;
	private static int diceNumber2 =0; // variables will hold dices numbers
	static int numberOfRolls = 0;
	public int rollDice () {
	
		return 1 + (int)(Math.random() * 6);// returns integer value in the range of [1;6]
	}
	
	public int rollsForEqualDices (int equality){
		numberOfRolls =0;
		diceNumber1 = rollDice();
		diceNumber2 = rollDice();
		while (diceNumber1!=equality || diceNumber2 !=equality)
		{
			diceNumber1 = rollDice();
			diceNumber2 = rollDice();
			numberOfRolls ++;			
		}
		return numberOfRolls;
	}
	
	public static void main(String[] args)
	{		
		System.out.println ("Total number of rolls to get 1 on both dices = "+numberOfRolls);
	}

}
